package com.bailiban.aigou.admin.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.bailiban.aigou.admin.dao.CarouselFigureDao;
import com.bailiban.aigou.admin.entity.CarouselFigure;
import com.bailiban.aigou.admin.service.ICarouselFigureService;
import com.bailiban.aigou.admin.utils.PageModel;
@Service
public class CarouselFigureServiceImpl implements ICarouselFigureService{
	@Autowired
	private CarouselFigureDao carouselFigureDao;
	/**
     * service 做逻辑控制
     * 1：这里才是返回前端页面所需要的pagemodel
     * 2：可以调用多个dao来实现逻辑 或者业务需要
     * 
     */
	@Transactional
	public PageModel<CarouselFigure> getCarouselFigurePages(int pageNo, int pageSize) {
		PageModel<CarouselFigure> carouselFigurePages = carouselFigureDao.getCarouselFigurePages(pageNo, pageSize);
		carouselFigurePages.setTotalRecords(carouselFigureDao.getCarouselFigureCount());
		
		System.out.println("service"+carouselFigurePages.getList().get(0).getUrl());
		return carouselFigurePages;
	}
  /**
   * 添加轮播业务逻辑
   */
	@Transactional
	public void addCarouselFigure(CarouselFigure CarouselFigure) {
		carouselFigureDao.addCarouselFigure(CarouselFigure);
		
	}

	@Transactional
	public CarouselFigure getCarouselFigureById(String id) {
		
		return carouselFigureDao.getCarouselFigureById(id);
	}

	@Transactional
	public void updateCarouselFigure(CarouselFigure CarouselFigure) {
		
		carouselFigureDao.updateCarouselFigure(CarouselFigure);
	}

	@Transactional
	public void deleteCarouselFigureById(String id) {
		carouselFigureDao.deleteCarouselFigureById(id);
		
	}

	@Transactional
	public List<CarouselFigure> getAllcarouselFigure() {
		
		return carouselFigureDao.getAllcarouselFigure();
	}
	

}
